/**
 * @format
 * @Author: TC
 * @Date: 2025-07-28 16:47:30
 * @Last Modified by: TC(tengchao@taqu.cn)
 * @Last Modified time: 2025-11-03 16:13:12
 */

import { BinFileData } from "db://assets/FrameWork/Util/BinUtility";
import { app } from "../../../../../FrameWork/App";
import { EShaderCaseBundleConst } from "../Const/ShaderCaseBundleConst";
import { EShaderCaseUIConst } from "../Const/ShaderCaseUIConst";

/**
 * 预加载管理
 */
export class ShaderCasePreloadManager {
    public loadList = [this._loadCfg, this._loadMainUI];

    /**
     * 加载配置
     * @param cb
     */
    private _loadCfg(cb?: () => void): void {
        app.resMgr.loadBin(EShaderCaseBundleConst.ShaderCase, "Config/jsonCfg", (bin) => {
            if (!bin) {
                app.log.error("加载配置表失败");
                return;
            }
            app.bin.parseBin(bin, (binDataList: BinFileData[]) => {
                app.cfgMgr.praseAllCfgToJson(binDataList, () => {
                    app.log.log("加载配置表成功");
                    if (cb) cb();
                });
            });
        });
    }

    /**
     * 加载主界面
     * @param cb
     */
    private _loadMainUI(cb?: () => void): void {
        app.resMgr.loadPrefab(EShaderCaseBundleConst.ShaderCase, "Prefab/Main/ShaderCaseMainUI", () => {
            if (cb) cb();
        });
    }

    public release(): void {}
}
